<script type="text/javascript">
function delEntry(entry, url)
{
	var valid = confirm('<?=$this->translate->_('profile_guestbook_delete')?>');
	
	if(valid)
	{
		$.post(url, { uid: entry }, function(data) {
			$("#"+ entry).fadeOut("slow");
		});
	}
}
</script>


<h1><?=$this->translate->_('profile_guestbook')?></h1>
		
<p><a href="<?=$this->url(array('controller' => 'index'),'index', true)?>">Forum</a><?=$this->getRootline(false, false, $this->uid)?></p>

<ul class="profile_tabs">
<li>
	<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/magnifier.png" alt="" title="" />
	<a href="<?=$this->url(array('controller' => 'profile', 'action' => 'index', 'uid' => $this->uid), 'profile', true)?>">
		<?=$this->translate->_('profile_details')?>
	</a>
</li>
	
<li>
	<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/book.png" alt="" title="" />
	<span><?=$this->translate->_('profile_guestbook')?></span> <span style="color:#666;">(<?=$this->gb_count?>)</span>
</li>
	
<?if($this->auth_uid == $this->uid):?>
	<li>
		<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/pencil.png" alt="" title="" />
		<a href="<?=$this->url(array('controller' => 'profile', 'action' => 'edit'), 'profile_edit', true)?>">
			<?=$this->translate->_('profile_edit')?>
		</a>
	</li>
	<li>
		<img style="position:relative; top:1px;" src="<?=$this->baseUrl()?>/static/gfx/icons/image.png" alt="" title="" />
		<a href="<?=$this->url(array('controller' => 'profile', 'action' => 'avatar'), 'profile_ava', true)?>">
			<?=$this->translate->_('profile_edit_ava')?>
		</a>
	</li>
<?endif;?>
</ul>
<br style="clear:left;" />

<?=$this->paginationControl($this->results, 'Sliding', 'pagination_control.phtml', array('route' => 'profile_gb_page', 'uid' => $this->uid))?>

<?if($this->count > 0):?>
	<?foreach($this->results AS $result):?>
		<div id="<?=$result['uid']?>" class="profile_guestbook_entry">
			<span class="guestbook_reply">
				<a href="<?=$this->url(array('action' => 'guestbook', 'uid' => $result['user_uid']), 'profile_gb', true)?>">
					<?=$this->translate->_('profile_guestbook_reply')?>
				</a>
			</span>
			
			<h2 class="profile_guestbook_header">
				<span><?=$this->datetime($result['date'], 'dd. MMMM YYY, HH:m')?></span>
				<br /><a href="<?=$this->url(array('action' => 'index', 'uid' => $result['user_uid']), 'profile', true)?>"><?=$this->GetAuthor($result['user_uid'])?></a>
			</h2>
			<p><?=nl2br($this->BBCode($this->escape($result['text'], null, 'utf-8')))?></p>
			
			<?if($this->auth_uid == $result['guestbook_uid'] OR $this->auth_role == 'admin'):?>
				<p class="profile_guestbook_delEntry">
					<a href="javascript:delEntry(<?=$result['uid']?>,'<?=$this->url(array('controller' => 'profile', 'action' => 'deleteGuestbookEntry'), 'default', true)?>');">
						<img src="<?=$this->baseUrl()?>/static/gfx/icons/bin.png" />
					</a>
				</p>
			<?elseif($result['is_deleted'] == 1):?>
				<p class="notice"><?=$this->translate->_('profile_guestbook_deleted')?></p>
			<?endif;?>
		</div>
	<?endforeach;?>
<?else:?>
	<p class="notice"><?=$this->translate->_('profile_guestbook_empty')?></p>
<?endif;?>


<?if($this->auth):?>
<h2><?=$this->translate->_('profile_guestbook_add')?></h2>
<form method="post" action="">
	<?=$this->partial('editor.phtml', array('translate' => $this->translate, 'deactivateSmileyCheckbox' => true))?>
</form>
<?endif;?>